# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libvncserver
pkgver=0.9.13
pkgrel=1
pkgdesc="Library to make writing a vnc server easy"
url="http://libvncserver.sourceforge.net/"
arch="all"
license="GPL-2.0-or-later"
depends_dev="
	libgcrypt-dev
	libjpeg-turbo-dev
	libpng-dev
	libice-dev
	libx11-dev
	libxdamage-dev
	libxext-dev
	libxfixes-dev
	libxi-dev
	libxinerama-dev
	libxrandr-dev
	libxtst-dev
	openssl-dev
	lzo-dev
	"
makedepends="$depends_dev cmake"
subpackages="$pkgname-dev"
source="https://github.com/LibVNC/libvncserver/archive/LibVNCServer-$pkgver.tar.gz
	"

# secfixes:
#   0.9.13-r0:
#     - CVE-2019-20839
#     - CVE-2019-20840
#     - CVE-2020-14397
#     - CVE-2020-14399
#     - CVE-2020-14400
#     - CVE-2020-14401
#     - CVE-2020-14402
#     - CVE-2020-14403
#     - CVE-2020-14404
#     - CVE-2020-14405
#   0.9.12-r1:
#     - CVE-2019-15681
#   0.9.11-r2:
#     - CVE-2018-7225
#   0.9.11-r0:
#     - CVE-2016-9941
#     - CVE-2016-9942

builddir="$srcdir"/libvncserver-LibVNCServer-$pkgver

build() {
	mkdir build
	cd build
	cmake \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DWITH_ZLIB=ON \
		-DWITH_LZO=ON \
		-DWITH_JPEG=ON \
		-DWITH_PNG=ON \
		-DWITH_SDL=ON \
		-DWITH_THREADS=ON \
		-DWITH_GNUTLS=ON \
		-DWITH_OPENSSL=ON \
		-DWITH_SYSTEMD=OFF \
		-DWITH_GCRYPT=ON \
		-DWITH_FFMPEG=ON \
		-DWITH_WEBSOCKETS=ON \
		-DWITH_SASL=ON \
		..
	make
}

check() {
	make -C build test
}

package() {
	make -C build install DESTDIR="$pkgdir"
}

sha512sums="18b0a1698d32bbdbfe6f65f76130b2a95860e3cc76e8adb904269663698c7c0ae982f451fda1f25e5461f096045d40a89d9014258f439366d5b4feaa4999d643  LibVNCServer-0.9.13.tar.gz"
